package alg20241121;

public class Text {
    public int massage(int[] nums) {
        int n = nums.length;
        //1 创建表
        if(n == 0) return 0;
        int[] f = new int[nums.length];
        int[] g = new int[nums.length];
        //2 初始化
        f[0] = nums[0];
        g[0] = 0;
        //3 填表
        for (int i = 1; i < nums.length; i++) {
            f[i] = g[i-1] + nums[i];
            g[i] = Math.max(f[i-1], g[i-1]);
        }
        //4 返回值
        return Math.max(f[n-1], g[n-1]);
    }
}
